Skip to content

Migrate/buffer to uint8array#232

Merged
BlobMaster41 merged 5 commits intomainfrom
migrate/buffer-to-uint8array
Feb 16, 2026
Merged

Migrate/buffer to uint8array#232
BlobMaster41 merged 5 commits intomainfrom
migrate/buffer-to-uint8array

Conversation

@BlobMaster41
Copy link
Contributor

@BlobMaster41 BlobMaster41 commented Feb 16, 2026

Description

Standardize binary data handling across the codebase by switching from Buffer to Uint8Array and adopting helper utilities from @btc-vision/bitcoin (toHex/fromHex/toBase64/fromBase64/equals/sha256). Update related types and function signatures (websocket payloads, merkle trees, block/transaction processing, API converters, broadcast/preimage routes, deployment encoder, etc.) and replace manual Buffer/from/toString conversions with the bitcoin helpers. Also bump several @btc-vision package versions in package.json. These changes improve consistency and interoperability of binary data handling and prepare the code for environments where Uint8Array is preferred.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Performance improvement
  • Consensus change (changes that affect state calculation or validation)
  • Refactoring (no functional changes)
  • Documentation update
  • CI/CD changes
  • Dependencies update

Checklist

Build & Tests

  • npm install completes without errors
  • npm run build completes without errors
  • npm test passes all tests

Code Quality

  • Code follows the project's coding standards
  • No new compiler warnings introduced
  • Error handling is appropriate
  • Logging is appropriate for debugging and monitoring

Documentation

  • Code comments added for complex logic
  • Public APIs are documented
  • README updated (if applicable)

Security

  • No sensitive data (keys, credentials) committed
  • No new security vulnerabilities introduced
  • RPC endpoints properly authenticated
  • Input validation in place for external data

OPNet Node Specific

  • Changes are compatible with existing network state
  • Consensus logic changes are documented and tested
  • State transitions are deterministic
  • WASM VM execution is reproducible across nodes
  • P2P protocol changes are backward-compatible (or migration planned)
  • Database schema changes include migration path
  • Epoch finality and PoC/PoW logic unchanged (or documented if changed)

Testing

Consensus Impact

Related Issues


By submitting this PR, I confirm that my contribution is made under the terms of the project's license.

Standardize binary data handling across the codebase by switching from Buffer to Uint8Array and adopting helper utilities from @btc-vision/bitcoin (toHex/fromHex/toBase64/fromBase64/equals/sha256). Update related types and function signatures (websocket payloads, merkle trees, block/transaction processing, API converters, broadcast/preimage routes, deployment encoder, etc.) and replace manual Buffer/from/toString conversions with the bitcoin helpers. Also bump several @btc-vision package versions in package.json. These changes improve consistency and interoperability of binary data handling and prepare the code for environments where Uint8Array is preferred.
@BlobMaster41 BlobMaster41 added documentation Improvements or additions to documentation enhancement New feature or request core component consensus-change breaking-change clarity labels Feb 16, 2026
Make defensive copies of Uint8Array data to prevent accidental mutation of shared buffers. Changes include slicing calldata in ContractEvaluator, returning copies of serialized input/output UTXOs in ContractEvaluation, copying various environment variable fields and originTweakedPublicKey in RustContract, and constructing revertData as a new Uint8Array. These are safety fixes to avoid side effects from consumers or native code modifying underlying buffers.
Replace .slice() calls with Uint8Array.from when creating/copying byte arrays across the VM/API/Rust boundary. This ensures true Uint8Array copies (avoiding shared ArrayBuffer/view issues) when parsing transactions, passing calldata, returning serialized UTXOs, and building Rust contract environment data. Updated files: BroadcastTransaction.ts, ContractEvaluator.ts, ContractEvaluation.ts, RustContract.ts.
Introduce an ESLint rule (eslint-rules/no-uint8array-tostring.ts) that warns against calling .toString() on Uint8Array/branded byte types (since it yields comma-separated decimals) and register it in eslint.config.js as opnet/no-uint8array-tostring (error). Update package.json to use a local @btc-vision/op-vm (file:../op-vm) and remove the opnet dependency. Adjust tests to use binary/Uint8Array representations and proper decoding: PluginBlockchainAPI tests now use Binary/Uint8Array for ids/hashes/inputs and expect hex strings, contract storage expects Uint8Array; PluginFilesystemAPI tests use TextDecoder.decode and Uint8Array for binary fixtures; PluginLoader test decodes parsed proto with TextDecoder. These changes prevent incorrect .toString() usage and align tests with byte/encoding handling.
@BlobMaster41 BlobMaster41 merged commit d3ec6f9 into main Feb 16, 2026
2 of 4 checks passed
@BlobMaster41 BlobMaster41 deleted the migrate/buffer-to-uint8array branch February 16, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change clarity consensus-change core component documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments